<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="<?php echo site_url("style.css"); ?>" type="text/css" />
<title><?php echo $pagetitle; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
	<!-- header starts here -->
<div id="header">
  <div id="header-content"> 
    <ul>
      <li><a href="<?php echo site_url("admin/login/"); ?>">Login</a></li>
    </ul>
  </div>
</div>

<div id="content-wrap">
	
	<div id="nav">
		<img src="<?php echo site_url("images/Nav_Head_Post.png"); ?>" alt="navigation header" class="no-border" />
		<a href="<?php echo site_url("review"); ?>"><img src="<?php echo site_url("images/Home_Off.png"); ?>" alt="home" class="no-border" /></a>
		<a href="<?php echo site_url("review/reviews/default/0/A"); ?>"><img src="<?php echo site_url("images/Reviews_On.png"); ?>" alt="reviews" class="no-border" /></a>
		<img src="<?php echo site_url("images/Nav2b.png"); ?>" alt="nav3" class="no-border" />
	</div>
		
	<div id="main_display">	
		
<?php

	$stitle = htmlspecialchars($series->name);
	echo"<div id=\"post\">
			<h1>$stitle</h1>
			<div id=\"newswrapper\">
			<p><b>Studio:</b> $series->studio &nbsp;&nbsp;&nbsp;&nbsp;";
			
		if	(strlen($series->genre) > 0) {
			echo"<b>Genre:</b> $series->genre <br />";
		} else {
			echo"<br />";
		}
			
	echo"<b>Aired:</b> $series->season  $series->year &nbsp;&nbsp;&nbsp;&nbsp;<b>Length:</b> $series->length Episodes<br />
		<b>User Average Rating:</b> ";
		/*require_once ('showaverage.php');
	echo"&nbsp;&nbsp;";
		$avgq = "SELECT numrat FROM (SELECT series, count(distinct user_id) AS numrat FROM ratings GROUP BY series) AS t WHERE series='$i'";
		$avgresult = @mysql_query ($avgq); // Run the query.
		$avgnum = mysql_num_rows ($avgresult); // How many results are there?
		
		if ($avgnum == 1) { // If it ran OK, display the records.
		
			while ($avgrow = mysql_fetch_array($avgresult, MYSQL_NUM)) {
					
					if ($avgrow[0] == 1) {
						echo"<a href=\"rateseries.php?$i\">($avgrow[0] rating)</a>";
					} else {
						echo"<a href=\"rateseries.php?$i\">($avgrow[0] ratings)</a>";
					}
			}
				
			mysql_free_result ($avgresult); // Free up the resources.
		} else {
			echo"<a href=\"rateseries.php?$i\">(0 ratings)</a>";
		}*/
	echo"</p>";
	
	foreach($reviews as $row){
		$title = htmlspecialchars($row->title);
		$post = nl2br($row->content);
		
		if($row->episode == 0){
			echo"<h1>$stitle - Preview</h1>";
		} else if($row->episode > 0 && $row->episode != 99){
			echo"<h1>$stitle - Episode $row->episode</h1>";
		} else {
			echo"<h1>$stitle - Complete Review</h1>";
		}
		
		echo "<h2>$title</h2>
				<div id=\"newsbody\">
					<h3>Posted by: $row->poster @ $row->posted</h3>
					<p>$post</p><br /><br />
				</div>";
	}

?>
</div></div><div id="postfoot"></div>
<div id="footer"><p>&copy;2010 Kevin Baumgardner</p></div>			
		</div>
	
	</div>

</div>
</body>
</html>
